

import datetime

class GMT(datetime.tzinfo):
	def utcoffset(self, *args, **kwargs):
		return datetime.timedelta(hours=0, minutes=0)
	def dst(self, *args, **kwargs):
		return datetime.timedelta(hours=0, minutes=0)
	def tzname(self, *args, **kwargs):
		return 'GMT'

class Pacific(datetime.tzinfo):
	def utcoffset(self, *args, **kwargs):
		return datetime.timedelta(hours=-8, minutes=0)
	def dst(self, *args, **kwargs):
		return datetime.timedelta(hours=0, minutes=0)
	def tzname(self, *args, **kwargs):
		return 'PST'

def parseWhatTimestamp(string):
	# Could replace the following with a call to timedate.strptime()
	month, day, year, time = string.split()
	day = int(day)
	assert(year.endswith(','))
	year = int(year[:-1])
	hour, minute = time.split(':')
	hour = int(hour)
	minute = int(minute)
	return datetime.datetime(year, getIntegralMonth(month), day, hour, minute, tzinfo=GMT())


months = (None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
monthsDict = None

def getIntegralMonth(string):
	global monthsDict
	if monthsDict is None:
		monthsDict = {}
		for index, month in enumerate(months):
			monthsDict[month] = index
	return monthsDict[string]

